<?php
/**
 * Created by JetBrains PhpStorm.
 * User: GJN
 * Date: 5/10/13
 * Time: 2:53 PM
 */
$link = mysql_connect('localhost:3306', 'team02', 'team02') or die('Can\'t connect to database - Error: ' . mysql_error());

mb_internal_encoding('UTF-8');
mysql_selectdb('php_study');
mysql_query("SET NAMES 'UTF8'", $link);
$sql = "INSERT INTO albums VALUES (null, 1, 'Chào buổi sáng')";
//mysql_query($sql, $link) or die('Can\t insert new data to database.<br/>');

$query = "SELECT * FROM artists";
$result = mysql_query($query, $link);
echo '<meta charset="utf-8"/>';
if (mysql_num_rows($result) > 0) {
    while ($row = mysql_fetch_assoc($result)) {
        foreach($row as $key => $val) {
            echo $key, ': ', $val, '<br/>';
        }
    }
}
$new_row = mysql_fetch_array($result);
$sql = null;

mysql_free_result($result);
mysql_close($link);